﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KeywordAuction;

namespace KeywordAuction
{
    public class Advertiser
    {
        public string Name { get; set; }
        public string Id { get; set; }
        public AuctionHost AttendingAuction { get; set; }
        public List<AdvertiserBidding> Biddings { get; set; }
        public List<IStrategy> Strategies { get; set; }
        public ITactics Tactics { get; set; }

        public IStrategy CurrentStrategy { get; set; }

        public double BudgetConstraint { get; set; }
        public double CurrentUsingBudget
        {
            get
            {
                return Biddings.Sum(p => p.Bid);
            }
        }
        public Advertiser()
        {
            Id = Guid.NewGuid().ToString();
            Biddings = new List<AdvertiserBidding>();
            Strategies = new List<IStrategy>();
            //Tactics = new ();
        }

        public double GetValue()
        {
            double totalValue = 0;
            foreach (var item in Biddings)
            {
                totalValue += item.GetValue();
            }
            return totalValue;
        }

        public static Advertiser CreateAdvertiser(AuctionHost host)
        {
            var advertiser = new Advertiser();

            advertiser.AttendingAuction = host;
            return advertiser;
        }

    }
}
